<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="description" content="">
		<meta http-equiv="x-dns-prefetch-control" content="on">
		<title>旅程列表</title>
		<link href="../imgv2/css/css.css" rel="stylesheet" type="text/css">
		<style type="text/css">
			#tripList {
				overflow-y: auto;
			}
		</style>
	</head>

	<body class="whitebg">
		<!--wrap start-->
		<section id="wrap">
			<section class="tabarea">
				<ul class="tabbg">
					<li class="tabbtn tabbtn_active" listtype="4" ordertype="6"><a href="javascript:void(0);">我创建的</a>
					</li>
					<li class="tabbtn" listtype="4" ordertype="7"><a href="javascript:void(0);">被邀请的</a>
					</li>
				</ul>
			</section>
			<section id="tripList" class="citylist whitebg">
				<!-- <a href="javascript:void(0);">
          <img src="img/user_pic.png" width="100%" height="100%" class="tripuser"/>
          <ul class="listitem h120 bottomline">
              <li class="triptitle mt10">春日旅行季，上海车友会黄山三...</li>
              <li class="tripinfo">
                  <p class="peoplenumber">参与人数：7 人</p>
                  <p class="status_green w160">旅程进行中</p>
              </li>
          </ul>
          </a>
          <a href="javascript:void(0);">
          <img src="img/user_pic.png" width="100%" height="100%" class="tripuser"/>
          <ul class="listitem h120 bottomline">
              <div class="triptitle mt10">春日旅行季，上海车友会黄山三...</div>
              <div class="tripinfo">
                  <p class="peoplenumber">参与人数：7 人</p>
                  <p class="status_blue w160">旅程准备中</p>
              </div>
          </ul>
          </a>
          <a href="javascript:void(0);">
          <img src="img/user_pic.png" width="100%" height="100%" class="tripuser"/>
          <ul class="listitem h120 bottomline">
              <div class="triptitle mt10">春日旅行季，上海车友会黄山三...</div>
              <div class="tripinfo">
                  <p class="peoplenumber">参与人数：7 人</p>
                  <p class="status_gray w160">旅程已结束</p>
              </div>
          </ul>
          </a> -->
			</section>
		</section>
	</body>
	<script src="../jsv2/jQuery/jquery-1.11.2.min.js"></script>
	<script src="../jsv2/lib/json3.min.js"></script>
	<script src="../jsv2/jsonMsg.js"></script>
	<script src="../jsv2/QueryStringParser.js"></script>
	<script src="../jsv2/journey/operateData.js"></script>
	<script src="../jsv2/common.js"></script>
	<script>
		var latLon = "",
			openId, innerContain, topListType = 1;
		$(function() {
			showMaskLoading();
			openId = queryString.getParam("openid");
			/*$('#tripList').on('click', 'a', function(e) {
				setIframeSrc('startJourney.html');
			});*/
			$('.tabbg li').on('click', function(e) {
				var tar = $(e.target),
					tar = _getTarparanet(tar, {
						key: 'tagName',
						'value': 'LI'
					}),
					listtype = tar.attr('listtype'),
					ordertype = tar.attr('ordertype');
				handleTripList(listtype, ordertype);
				$('.tabbg li').removeClass('tabbtn_active');
				tar.addClass('tabbtn_active');
			});
			$('.tabbtn_active').click();
			//$('#tripList').css({'height':document.body.clientHeight-72+'px'});
		});

		function addTrip() {
			window.location.href = "create_trip.html?openid=" + openId;
		}

		function handleTripList(listType, orderType) {
			if (openId == null || openId == "") {
				//return false;	
			} else {
				if (listType == 0) {
					listType = topListType;
				} else {
					topListType = listType;
				}
				var dataStr = {
					ListType: parseInt(listType),
					OrderType: parseInt(orderType),
					Cursor: 0,
					Limit: 15,
					Direction: 0
				};
				bidgeToWeixin(openId, 'ListTrip', dataStr, function(data, status, xhr) {
					if (data.portalResp.Data.trips && data.portalResp.Data.trips.length > 0) {
						var tripsList = data.portalResp.Data.trips,
							innerContain = [],
							trip;
						$.each(tripsList, function(index) {
							if (index == 0) {
								$(".citylist").html("");
								innerContain = [];
							}
							trip = tripsList[index];
							var urlString = "trip_leader.html";
							var color = "green";
							var rightContent = "旅程进行中";
							if (trip.status == '1') {
								urlString = "trip_leader.html"; //代表active trip
							} else if (trip.status == '0') {
								//rightContent = tripsList[index].ValidDate + "过期";
								color = "blue";
								rightContent = "旅程准备中";
							} else {
								//rightContent = tripsList[index].ValidDate + "过期";
								color = "gray";
								rightContent = "旅程已结束";
							}
							var flag = 0;
							if (tripsList[index].isActive) {
								flag = 1;
							}
							if (tripsList[index].TripLeader == openId) {
								innerContain.push("<a href='trip_detail.html?status="+trip.status+"&isActive=" + flag + "&openid=" + openId + "&tripid=" + tripsList[index].TripID + "'>");
							} else {
								innerContain.push("<a href='trip_member.html?status="+trip.status+"&isActive=" + flag + "&openid=" + openId + "&tripid=" + tripsList[index].TripID + "'>");
							}
							//innerContain.push("	<div class='list_group'>");
							innerContain.push("	      <img src='" + tripsList[index].LeaderPortrait + "' width='100%' height='100%' class='tripuser'>");
							innerContain.push("	      <ul class='listitem h120 bottomline'>");
							innerContain.push("	           <div class='triptitle'>" + tripsList[index].Title + "</div>");
							innerContain.push("	           <div class='tripinfo'>");
							innerContain.push("	                <p class='peoplenumber'>参与人数：" + tripsList[index].MemberNumber + "人</p>");
							innerContain.push("	                <p class='status_" + color + "'>" + rightContent + "</p>");
							innerContain.push("	           </div>");
							innerContain.push("	      </ul>");
							//innerContain.push("	</div>");
							innerContain.push("</a>");
						});
						$("#tripList").html(innerContain.join(''));
					} else {
						$("#tripList").html("");
					}
					closemaskLoading();//关闭这招层
				});
			}
		}
	</script>

</html>